fix(vulnfeeds): detect when version range has introduced >= fixed#4551
Open
Harshit28j wants to merge 3 commits intogoogle:masterfrom
Open
fix(vulnfeeds): detect when version range has introduced >= fixed#4551Harshit28j wants to merge 3 commits intogoogle:masterfrom
Harshit28j wants to merge 3 commits intogoogle:masterfrom
Conversation
Contributor
|
Great work. Would you mind adding a testcase to cover this change? Thanks! |
Author
|
@jess-lowe Added test cases and updated the branch since it was outdated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixes #215
Added a check to detect when CVE data has invalid version ranges where the
introducedversion comes after thefixedversion according to thevalidVersionsordering.Details
Problem:
For PyPI vulnfeeds, there are cases of bad CVE data where
introduced: 1.0andfixed: 1.0b4. In Python versioning (PEP 440),1.0b4(beta) comes before1.0(final release), making this range logically impossible.❌ BAD DATA (triggers warning): Version: 1.0a1 1.0a2 1.0b1 1.0b4 1.0rc1 1.0 1.1 Index: 0 1 2 3 4 5 6 ↑ ↑ fixed introduced (idx 3) (idx 5)Problem: 5 >= 3 → introduced comes AFTER fixed (impossible!)
Solution:
Added a check in ExtractVersionInfo (vulnfeeds/cves/versions.go) that compares the positions of
introducedandfixedversions in thevalidVersionsslice. Whenintroduced >= fixed, a warning is appended:Result: Warning generated⚠️
✅ GOOD DATA (no warning): Version: 1.0a1 1.0a2 1.0b1 1.0b4 1.0rc1 1.0 1.1 Index: 0 1 2 3 4 5 6 ↑ ↑ introduced fixed (idx 0) (idx 3)Result: 0 < 3 → Valid range ✅
Warning: introduced version 1.0 >= fixed version 1.0b4Changes:
Testing
go test ./cves/)validVersionsis empty